case APCOND_AGE:
$age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
return $age >= $cond[1];
+ case APCOND_AGE_FROM_EDIT:
+ $age = time() - wfTimestampOrNull( TS_UNIX, $user->getFirstEditTimestamp() );
+ return $age >= $cond[1];
case APCOND_INGROUPS:
$groups = array_slice( $cond, 1 );
return count( array_intersect( $groups, $user->getGroups() ) ) == count( $groups );
define( 'APCOND_INGROUPS', 4 );
define( 'APCOND_ISIP', 5 );
define( 'APCOND_IPINRANGE', 6 );
+define( 'APCOND_AGE_FROM_EDIT', 7 );
* non-existent/anonymous user accounts.
*/
public function getRegistration() {
- return $this->mId > 0
+ return $this->getId() > 0
? $this->mRegistration
: false;
}
+
+ /**
+ * Get the timestamp of the first edit
+ *
+ * @return \types{\string,\bool} string Timestamp of first edit, or false for
+ * non-existent/anonymous user accounts.
+ */
+ public function getFirstEditTimestamp() {
+ if( $this->getId() == 0 ) return false; // anons
+ $dbr = wfGetDB( DB_SLAVE );
+ $time = $dbr->selectField( 'revision', 'rev_timestamp',
+ array( 'rev_user' => $this->getId() ),
+ __METHOD__,
+ array( 'ORDER BY' => 'rev_timestamp ASC' )
+ );
+ if( !$time ) return false; // no edits
+ return wfTimestamp( TS_MW, $time );
+ }
/**
* Get the permissions associated with a given list of groups